/*
 * @Author: Eli.Chen
 * @Date: 2025-03-03 16:23:45
 * @LastEditors: Eli.Chen
 * @LastEditTime: 2025-03-24 16:29:12
 * @Description: 社区API
 */
import axiosRequest from '@/utils/request';

// 获取社区列表
export function getCommunityList(userId, cityId) {
    let url = `/com/thread/list?userId=${userId}`;
    if (cityId) {
        url += `&cityId=${cityId}`;
    }
    return axiosRequest({
        url: url,
        method: 'GET',
    });
}

export function getCommunityUserInfo(userId) {
    return axiosRequest({
        url: `/com/post-stats/${userId}`,
        method: 'GET',
    });
}

export function sendComment(data) {
    return axiosRequest({
        url: '/com/comment',
        method: 'POST',
        data: data,
    });
}

export function deleteComment(commentId) {
    return axiosRequest({
        url: `/com/comment/${commentId}`,
        method: 'DELETE',
    });
}

export function createThread(data) {
    return axiosRequest({
        url: '/com/thread/create',
        method: 'POST',
        data: data,
    });
}

export function toggleAction(actionType, postId) {
    return axiosRequest({
        url: `/com/toggle?actionType=${actionType}&postId=${postId}`,
        method: 'POST',
    });
}

export function publishPost(data) {
    return axiosRequest({
        url: '/com/thread/publish',
        method: 'POST',
        data: data,
    });
}
